package com.ag.zlw.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.ag.bean.TbWorkDay;
import com.ag.common.BaseAction;
import com.ag.common.IDUtil;
import com.ag.zlw.service.WorkDayService;

/**
 * 工作日
 * 
 * @author 钟龙伟
 * 
 */

@Scope("prototype")
@Controller("WorkDayAction")
public class WorkDayAction extends BaseAction {
	private static final long serialVersionUID = -1478025497648926124L;
	@Resource(name = "WorkDayService")
	private WorkDayService service;
	private List<TbWorkDay> WorkDayList;
	private String message;
	private String wdId;
	private String wdType;

	TbWorkDay tbWorkDay = new TbWorkDay();

	public String find() {
		try {
			WorkDayList = service.findAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "main";
	}

	public String delete() {
		tbWorkDay.setWdId(wdId);
		try {
			service.delete(tbWorkDay);
			this.setMessage("delete success!");
		} catch (Exception e) {
			this.setMessage("delete fail!");
		}
		return "delete_success";
	}

	public String add() {
		tbWorkDay.setWdType(wdType);
		tbWorkDay.setA(IDUtil.PRESERVE);
		try {
			service.save(tbWorkDay);
			this.setMessage("save success!");
		} catch (Exception e) {
			this.setMessage("save fail!");
		}
		return "add_success";
	}

	public String modify() {
		tbWorkDay.setWdId(wdId);
		tbWorkDay.setWdType(wdType);
		tbWorkDay.setA(IDUtil.PRESERVE);
		try {
			service.modify(tbWorkDay);
			this.setMessage("modify success!");
		} catch (Exception e) {
			this.setMessage("modify fail!");
		}
		return "modify_success";
	}

	public List<TbWorkDay> getWorkDayList() {
		return WorkDayList;
	}

	public void setWorkDayList(List<TbWorkDay> workDayList) {
		this.WorkDayList = workDayList;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getWdId() {
		return wdId;
	}

	public void setWdId(String wdId) {
		this.wdId = wdId;
	}

	public String getWdType() {
		return wdType;
	}

	public void setWdType(String wdType) {
		this.wdType = wdType;
	}

}
